package order.service.impl;

import order.feign.FeignStorageService;
import order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    RestTemplate restTemplate;

    @Autowired
    FeignStorageService feignStorageService;

    @Override
    public String orderByRest(String params) {
        String result = restTemplate.getForEntity("http://service-storage/storage", String.class).getBody();
        System.out.println("扣减库存结果：" + result);
        return "order success";
    }

    @Override
    public String orderByFeign(String params) {
        String result = feignStorageService.storage();
        System.out.println("扣减库存结果：" + result);
        return "order success";
    }

}
